/* eslint-disable no-use-before-define */

import axios, { type Paging, type Response } from '@/utils/axios/axios';
import mxpGetSysInfoStore from '@/mxp-ui/mxp-tool/store/mxp-store-sys-info';
import { getAppInfo } from '@/config/mp-config';

/*埋点上报*/
export function userActionLog(data: dataPointType) {
  const sys = mxpGetSysInfoStore().getSysInfo().value;
  const appInfo = getAppInfo()?.appCode;
  const logData = {
    userId: data.userId,
    // platform: sys.uniPlatform,
    // appCode: appInfo,
    eventType: data.eventType,
    params: data.data,
    errorMsg: data?.msg,
  };
  return axios.post(`/app/errorRecord/add`, logData);
}

export type dataPointType = {
  /**用户id*/
  userId: number | undefined;
  /**操作数据*/
  data: string;
  /**事件类型*/
  eventType: string;
  /**消息*/
  msg?: string;
};
